#ifndef SERIALPORTCLIENT_H
#define SERIALPORTCLIENT_H

#include <QObject>
#include <QThread>
#include <QDebug>
#include <QSerialPortInfo>
#include <QSerialPort>
#include "loghelper.h"
#include <CommonHelper.h>
#include <dbHelper.h>
#include "qmlSignal.h"

class SerialportClient:public QSerialPort
{
    Q_OBJECT;

public:
    QString equId;
    int experimentStatus;
    int tempOrder;
    int reInfoStatus;
    QString experimentGuid;
    QString chartStatus;
    QString step;
    QString cycle;
    QString temp;
    QString tempTwo;
    QString tempThree;
    QString tempFour;
    QString tempFive;
    QString tempSix;
    QString allerror;

public:
    void serialclose();
    void serialPortSend(QByteArray);
    explicit SerialportClient(QObject *parent = nullptr);
    bool IsOnline();

signals:
    void SignalConnectToHost(const QString & address, QString port);

    void successStart();
    //转换来自主线程的发送操作
    void SignalSendingData(const QByteArray c_btaData);

public:
    void ClientConnectToHost(const QString &address, QString port);
    void ClientSendingData(const QByteArray &c_btaData);

private:
    QThread thread;
    loghelper * logClient;
    CommonHelper* common;
    bool m_bOnLine = false;
    QString tempString;
    QMap<QString, QString> *mapGZ;
};

#endif // SERIALPORTCLIENT_H
